package com.boatAnchorAssistant.service.controller.app;

import com.boatAnchorAssistant.pojo.param.alarm.*;
import com.boatAnchorAssistant.pojo.vo.alarm.GetAlarmChartListVo;
import com.boatAnchorAssistant.pojo.vo.alarm.GetAlarmDownListVo;
import com.boatAnchorAssistant.pojo.vo.alarm.GetAlarmListVo;
import com.boatAnchorAssistant.pojo.vo.alarm.GetAlarmVo;
import com.boatAnchorAssistant.pojo.vo.notice.GetNoticeVo;
import com.boatAnchorAssistant.service.service.in.AlarmService;
import nirvana.core.domains.vo.ApiResult;
import nirvana.core.domains.vo.PageResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * app/报警列表
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/alarm/app")
public class AlarmAppController {

    private final AlarmService service;

    public AlarmAppController(AlarmService service) {
        this.service = service;
    }


    /**
     * 获取报警列表详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getAlarm")
    public ApiResult<GetAlarmVo> getAlarm(@RequestParam("id") Long id) {
        GetAlarmVo vo = service.getAlarm(id);
        return ApiResult.ok(vo);
    }

    /**
     * 获取最近的一条报警
     *
     * @return
     */
    @GetMapping("/selectOneAlarm")
    public ApiResult<GetAlarmVo> selectOneAlarm() {
        GetAlarmVo vo = service.selectOneAlarm();
        return ApiResult.ok(vo);
    }

    /**
     * 修改报警状态
     *
     * @param param
     * @return
     */
    @PostMapping("/updateAlarmStatus")
    public ApiResult updateAlarmStatus(@RequestBody @Valid UpdateAlarmStatusParam param) {
        service.updateAlarmStatus(param);
        return ApiResult.ok();
    }

    /**
     * 获取报警列表列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getAlarmList")
    public ApiResult<PageResult<GetAlarmListVo>> getAlarmList(@RequestBody GetAlarmListParam param) {
        param.setIsDataSegregation(true);
        PageResult<GetAlarmListVo> result = service.getAlarmList(param);
        return ApiResult.ok(result);
    }

    /**
     * 首页-事件报警查询
     *
     * @return
     */
    @PostMapping("/getAlarmChartList")
    public ApiResult<List<GetAlarmChartListVo>> getAlarmChartList(@RequestBody(required = false) @Valid GetAlarmChartListParam param) {
        List<GetAlarmChartListVo> list = service.getAlarmChartList(param);
        return ApiResult.ok(list);
    }
}

